{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第二章习题\n",
    "\n",
    "### 一、填空题\n",
    "\n",
    "1.列表的`sort()`方法没有返回值,或者说返回值为_____none____."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.已知列表 `data=[1,2,30 4]`，那么`data[2:100]`的值为___30,4_____."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.己知`x=3`和`y=5`,那么执行语句`x,y=y,x`之后，`y`的值为______3__________."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4．已知字典 `data= {'a;97, 'A' :65}`,那么`data.get('a', None)`的值为______97_________."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 二、判断题\n",
    "\n",
    "1.生成器表达式的计算结果是一个元组。`( F   )`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2．包含列表的元组可以作为字典的“键”。`(  F  )`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3．包含列表的元组不可以作为集合的元素。`(  T  )`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4．列表的`rindex()`方法返回指定元素在列表中最后一次出现的位置。`( T   )`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 三、编程题\n",
    "\n",
    "1.输入一个字符串，输出其中每个字符的出现次数。要求使用标准库`collotections`中的`Counter`类,请自行查阅相关用法。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入字符串123456\n",
      "Counter({'1': 1, '2': 1, '3': 1, '4': 1, '5': 1, '6': 1})\n"
     ]
    }
   ],
   "source": [
    "from collections import Counter\n",
    "a = input(\"请输入字符串\")\n",
    "b = Counter(a)\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2．输入一个字符串,输出其中只出现了一次的字符及其下标。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入一个字符串：\"123456\"\n"
     ]
    }
   ],
   "source": [
    "text = input('请输入一个字符串：')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3．输入一个字符串,输出其中每个唯一字符最后一次出现的下标。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入字符内容：123456\n",
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "x = input('请输入字符内容：')\n",
    "d = {}\n",
    "for i in x:\n",
    "    d[i] = d.get(i, 0) + 1\n",
    "for j in d:\n",
    "    if d[j] == 1:\n",
    "        print(x.index(j))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4．输入包含若干集合的列表，输出这些集合的并集。提示:使用`reduce()`函数和`operator`模块中的运算实现多个集合的并集。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入包含若干集合的列表：[{20,30},{30}]\n"
     ]
    }
   ],
   "source": [
    "from functools import reduce\n",
    "from operator import __or__\n",
    "x = eval(input('请输入包含若干集合的列表：'))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5．输入一个字符串,检查该字符串是否为回文（正着读和反看读都一样的字符串)，如果是就输出`Yes`，否则输出`No`。要求使用切片实现"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入一个字符串'1234'\n",
      "NO\n"
     ]
    }
   ],
   "source": [
    "str1 = input('请输入一个字符串')\n",
    "str2 = str1[::-1]\n",
    "if str1 == str2:\n",
    "    print('YES')\n",
    "else:\n",
    "    print('NO')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 课本上65页课后习题"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：1. 可迭代对象 答案：2. 4 答案：3. None 答案：4. remove() 答案：5. [6,7,9,11] 答案：6. {}；键；值；键 答案：7. items();key();values() 答案：8. ['dict(zip(a,b))'] 答案：9. b = a[::3] 答案：10. 5 for i in range(10) 答案：11. 不可以"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "12.data = ['sfcgtrtj46680','34fsr','68hff','dd','0.2']\n",
    "print(list(filter(lambda s:len(set(s))/len(s)>0.5,data)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]\n"
     ]
    }
   ],
   "source": [
    "def prime(x):                       \n",
    "    for i in range(2,x):\n",
    "        if x%i==0:\n",
    "            return False\n",
    "        if i==x-1:\n",
    "            return True\n",
    "output=filter(prime,range(2,1001))\n",
    "print(list(output))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "14.当列表从中间或从头增加或删除元素时,列表对象自动进行内存扩展或收缩,从而保证元素之间没有缝隙,但这涉及到列表元素的大量的移动,效率较低,应尽量从列表尾部进行元素的增加与删除操作以提高处理速度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[93, 19, 63, 32, 67, 77, 50, 29, 35, 33, 83, 79, 86, 0, 43, 23, 39, 16, 41, 54, 29, 11, 55, 12, 95, 5, 16, 69, 59, 25, 1, 26, 74, 85, 18, 6, 33, 75, 23, 51, 46, 33, 15, 79, 57, 72, 71, 79, 33, 80, 0, 50, 92, 62, 8, 40, 33, 36, 58, 2, 46, 77, 82, 8, 11, 20, 36, 67, 65, 0, 74, 17, 24, 73, 8, 74, 88, 39, 7, 64, 17, 93, 3, 52, 37, 38, 20, 46, 7, 90, 100, 75, 30, 44, 53, 77, 3, 84, 51, 97, 59, 62, 24, 13, 25, 10, 100, 89, 49, 49, 58, 90, 53, 37, 34, 54, 100, 80, 76, 77, 3, 44, 44, 69, 81, 79, 100, 61, 52, 97, 47, 88, 75, 24, 98, 24, 83, 26, 62, 79, 20, 78, 66, 3, 24, 37, 38, 81, 5, 16, 7, 60, 48, 1, 69, 51, 16, 14, 23, 14, 28, 54, 53, 23, 100, 42, 24, 65, 60, 90, 28, 5, 34, 50, 83, 23, 31, 37, 54, 55, 31, 4, 53, 84, 82, 10, 92, 1, 52, 45, 97, 6, 14, 26, 71, 58, 1, 85, 80, 61, 70, 28, 6, 93, 28, 10, 36, 49, 41, 54, 28, 50, 91, 72, 53, 88, 77, 61, 32, 72, 37, 73, 66, 54, 98, 60, 79, 0, 25, 21, 6, 88, 77, 75, 53, 35, 4, 0, 46, 42, 19, 82, 100, 21, 40, 91, 42, 41, 65, 24, 42, 72, 46, 58, 17, 2, 60, 27, 91, 45, 41, 89, 47, 42, 44, 44, 88, 40, 33, 11, 98, 45, 92, 76, 85, 16, 0, 73, 11, 85, 24, 75, 65, 28, 22, 33, 64, 38, 81, 70, 52, 40, 61, 92, 14, 39, 18, 6, 59, 12, 35, 64, 55, 65, 86, 17, 34, 8, 64, 79, 9, 4, 74, 53, 39, 8, 97, 57, 99, 81, 69, 33, 94, 44, 19, 0, 22, 9, 40, 87, 57, 40, 55, 21, 24, 65, 51, 55, 5, 84, 34, 34, 46, 91, 96, 88, 66, 50, 7, 90, 78, 36, 31, 35, 33, 4, 32, 83, 8, 31, 73, 14, 35, 22, 60, 49, 26, 55, 65, 22, 68, 69, 40, 19, 55, 76, 62, 75, 39, 28, 5, 56, 45, 60, 30, 68, 97, 48, 43, 8, 86, 62, 72, 68, 3, 57, 92, 99, 37, 92, 10, 52, 22, 28, 89, 95, 13, 65, 79, 33, 5, 16, 41, 62, 88, 29, 3, 42, 19, 6, 79, 71, 78, 39, 82, 30, 1, 83, 38, 73, 48, 51, 65, 56, 1, 55, 86, 48, 58, 56, 92, 77, 94, 77, 55, 29, 88, 58, 32, 20, 5, 83, 6, 72, 34, 6, 24, 2, 44, 81, 74, 66, 88, 53, 77, 16, 23, 81, 56, 11, 52, 66, 54, 81, 12, 100, 24, 55, 23, 79, 54, 10, 96, 27, 35, 37, 97, 37, 61, 43, 26, 27, 34, 67, 15, 12, 50, 14, 51, 90, 58, 38, 92, 7, 14, 1, 62, 1, 99, 93, 92, 66, 1, 71, 54, 57, 21, 4, 50, 88, 10, 81, 67, 86, 99, 52, 98, 6, 10, 34, 66, 99, 38, 49, 51, 38, 100, 66, 33, 37, 94, 1, 84, 41, 89, 34, 30, 7, 0, 42, 45, 70, 78, 53, 8, 35, 93, 50, 30, 94, 33, 87, 37, 8, 95, 54, 39, 46, 42, 22, 42, 20, 53, 33, 22, 83, 30, 81, 30, 52, 43, 1, 52, 71, 91, 50, 77, 44, 92, 31, 64, 84, 75, 79, 78, 49, 65, 42, 72, 40, 63, 37, 67, 21, 62, 97, 75, 40, 40, 79, 2, 50, 31, 3, 80, 92, 54, 52, 52, 96, 48, 28, 81, 77, 77, 0, 80, 9, 82, 40, 53, 19, 48, 6, 95, 82, 80, 86, 67, 98, 91, 33, 59, 80, 95, 11, 69, 74, 55, 14, 20, 28, 74, 72, 24, 16, 55, 28, 7, 28, 53, 74, 10, 67, 96, 3, 7, 12, 27, 42, 40, 47, 33, 11, 79, 61, 67, 88, 70, 15, 13, 16, 71, 28, 42, 34, 77, 85, 82, 97, 73, 73, 26, 58, 12, 72, 10, 97, 84, 56, 37, 6, 8, 37, 43, 33, 95, 81, 63, 43, 16, 61, 91, 68, 64, 0, 22, 88, 10, 67, 62, 79, 70, 35, 92, 94, 29, 91, 20, 30, 58, 43, 65, 85, 78, 28, 1, 18, 14, 29, 43, 62, 2, 100, 22, 23, 53, 71, 13, 25, 10, 71, 31, 94, 64, 29, 91, 100, 39, 8, 98, 82, 4, 100, 57, 99, 62, 47, 68, 96, 98, 25, 34, 10, 5, 48, 39, 16, 10, 2, 54, 64, 56, 53, 85, 1, 100, 55, 70, 16, 40, 56, 63, 57, 53, 52, 83, 20, 49, 60, 93, 64, 27, 77, 29, 100, 86, 57, 10, 89, 8, 35, 20, 27, 4, 95, 2, 40, 98, 57, 54, 66, 55, 90, 57, 80, 85, 97, 66, 88, 70, 66, 71, 10, 76, 98, 25, 65, 45, 87, 11, 23, 24, 65, 76, 34, 62, 41, 6, 15, 39, 14, 32, 90, 4, 78, 33, 35, 14, 49, 99, 30, 42, 53, 1, 39, 0, 36, 25, 5, 8, 92, 12, 32, 83, 58, 17, 68, 43, 5, 11, 5, 94, 67, 45, 91, 7, 7, 37, 80, 56, 64, 97, 79, 85, 88, 53, 62, 5, 89, 53, 13, 91, 33, 97, 10, 28, 89, 55, 4, 85, 25, 43, 40, 47, 26, 64, 20, 67, 34, 90, 100, 23, 30, 13, 30, 94, 87, 24, 94, 26, 29, 99, 99, 92, 17, 56, 67, 59, 32, 76, 48, 60, 64, 27, 90, 25, 97, 73, 41, 38, 19, 0, 54, 80, 74, 92, 52, 62, 51, 2, 15, 34, 19, 40, 54, 56, 4, 66, 15, 33, 5, 9, 96, 99, 35, 8, 86, 89, 30, 73, 6, 80, 82, 45, 81, 7, 20, 78, 82, 71, 8, 59, 42, 40, 5, 11, 24, 91, 39]\n",
      "93 : 6\n",
      "19 : 8\n",
      "63 : 4\n",
      "32 : 7\n",
      "67 : 12\n",
      "77 : 14\n",
      "50 : 10\n",
      "29 : 9\n",
      "35 : 11\n",
      "33 : 19\n",
      "83 : 9\n",
      "79 : 15\n",
      "86 : 8\n",
      "0 : 12\n",
      "43 : 10\n",
      "23 : 10\n",
      "39 : 12\n",
      "16 : 12\n",
      "41 : 8\n",
      "54 : 15\n",
      "29 : 9\n",
      "11 : 10\n",
      "55 : 15\n",
      "12 : 7\n",
      "95 : 7\n",
      "5 : 14\n",
      "16 : 12\n",
      "69 : 6\n",
      "59 : 6\n",
      "25 : 9\n",
      "1 : 14\n",
      "26 : 8\n",
      "74 : 9\n",
      "85 : 10\n",
      "18 : 3\n",
      "6 : 13\n",
      "33 : 19\n",
      "75 : 8\n",
      "23 : 10\n",
      "51 : 8\n",
      "46 : 7\n",
      "33 : 19\n",
      "15 : 6\n",
      "79 : 15\n",
      "57 : 10\n",
      "72 : 9\n",
      "71 : 10\n",
      "79 : 15\n",
      "33 : 19\n",
      "80 : 11\n",
      "0 : 12\n",
      "50 : 10\n",
      "92 : 15\n",
      "62 : 14\n",
      "8 : 15\n",
      "40 : 17\n",
      "33 : 19\n",
      "36 : 5\n",
      "58 : 10\n",
      "2 : 8\n",
      "46 : 7\n",
      "77 : 14\n",
      "82 : 10\n",
      "8 : 15\n",
      "11 : 10\n",
      "20 : 11\n",
      "36 : 5\n",
      "67 : 12\n",
      "65 : 13\n",
      "0 : 12\n",
      "74 : 9\n",
      "17 : 6\n",
      "24 : 15\n",
      "73 : 9\n",
      "8 : 15\n",
      "74 : 9\n",
      "88 : 14\n",
      "39 : 12\n",
      "7 : 11\n",
      "64 : 12\n",
      "17 : 6\n",
      "93 : 6\n",
      "3 : 8\n",
      "52 : 13\n",
      "37 : 14\n",
      "38 : 8\n",
      "20 : 11\n",
      "46 : 7\n",
      "7 : 11\n",
      "90 : 9\n",
      "100 : 14\n",
      "75 : 8\n",
      "30 : 12\n",
      "44 : 8\n",
      "53 : 18\n",
      "77 : 14\n",
      "3 : 8\n",
      "84 : 6\n",
      "51 : 8\n",
      "97 : 13\n",
      "59 : 6\n",
      "62 : 14\n",
      "24 : 15\n",
      "13 : 6\n",
      "25 : 9\n",
      "10 : 16\n",
      "100 : 14\n",
      "89 : 8\n",
      "49 : 8\n",
      "49 : 8\n",
      "58 : 10\n",
      "90 : 9\n",
      "53 : 18\n",
      "37 : 14\n",
      "34 : 14\n",
      "54 : 15\n",
      "100 : 14\n",
      "80 : 11\n",
      "76 : 6\n",
      "77 : 14\n",
      "3 : 8\n",
      "44 : 8\n",
      "44 : 8\n",
      "69 : 6\n",
      "81 : 12\n",
      "79 : 15\n",
      "100 : 14\n",
      "61 : 7\n",
      "52 : 13\n",
      "97 : 13\n",
      "47 : 5\n",
      "88 : 14\n",
      "75 : 8\n",
      "24 : 15\n",
      "98 : 9\n",
      "24 : 15\n",
      "83 : 9\n",
      "26 : 8\n",
      "62 : 14\n",
      "79 : 15\n",
      "20 : 11\n",
      "78 : 8\n",
      "66 : 12\n",
      "3 : 8\n",
      "24 : 15\n",
      "37 : 14\n",
      "38 : 8\n",
      "81 : 12\n",
      "5 : 14\n",
      "16 : 12\n",
      "7 : 11\n",
      "60 : 8\n",
      "48 : 8\n",
      "1 : 14\n",
      "69 : 6\n",
      "51 : 8\n",
      "16 : 12\n",
      "14 : 11\n",
      "23 : 10\n",
      "14 : 11\n",
      "28 : 15\n",
      "54 : 15\n",
      "53 : 18\n",
      "23 : 10\n",
      "100 : 14\n",
      "42 : 14\n",
      "24 : 15\n",
      "65 : 13\n",
      "60 : 8\n",
      "90 : 9\n",
      "28 : 15\n",
      "5 : 14\n",
      "34 : 14\n",
      "50 : 10\n",
      "83 : 9\n",
      "23 : 10\n",
      "31 : 7\n",
      "37 : 14\n",
      "54 : 15\n",
      "55 : 15\n",
      "31 : 7\n",
      "4 : 10\n",
      "53 : 18\n",
      "84 : 6\n",
      "82 : 10\n",
      "10 : 16\n",
      "92 : 15\n",
      "1 : 14\n",
      "52 : 13\n",
      "45 : 8\n",
      "97 : 13\n",
      "6 : 13\n",
      "14 : 11\n",
      "26 : 8\n",
      "71 : 10\n",
      "58 : 10\n",
      "1 : 14\n",
      "85 : 10\n",
      "80 : 11\n",
      "61 : 7\n",
      "70 : 7\n",
      "28 : 15\n",
      "6 : 13\n",
      "93 : 6\n",
      "28 : 15\n",
      "10 : 16\n",
      "36 : 5\n",
      "49 : 8\n",
      "41 : 8\n",
      "54 : 15\n",
      "28 : 15\n",
      "50 : 10\n",
      "91 : 12\n",
      "72 : 9\n",
      "53 : 18\n",
      "88 : 14\n",
      "77 : 14\n",
      "61 : 7\n",
      "32 : 7\n",
      "72 : 9\n",
      "37 : 14\n",
      "73 : 9\n",
      "66 : 12\n",
      "54 : 15\n",
      "98 : 9\n",
      "60 : 8\n",
      "79 : 15\n",
      "0 : 12\n",
      "25 : 9\n",
      "21 : 5\n",
      "6 : 13\n",
      "88 : 14\n",
      "77 : 14\n",
      "75 : 8\n",
      "53 : 18\n",
      "35 : 11\n",
      "4 : 10\n",
      "0 : 12\n",
      "46 : 7\n",
      "42 : 14\n",
      "19 : 8\n",
      "82 : 10\n",
      "100 : 14\n",
      "21 : 5\n",
      "40 : 17\n",
      "91 : 12\n",
      "42 : 14\n",
      "41 : 8\n",
      "65 : 13\n",
      "24 : 15\n",
      "42 : 14\n",
      "72 : 9\n",
      "46 : 7\n",
      "58 : 10\n",
      "17 : 6\n",
      "2 : 8\n",
      "60 : 8\n",
      "27 : 7\n",
      "91 : 12\n",
      "45 : 8\n",
      "41 : 8\n",
      "89 : 8\n",
      "47 : 5\n",
      "42 : 14\n",
      "44 : 8\n",
      "44 : 8\n",
      "88 : 14\n",
      "40 : 17\n",
      "33 : 19\n",
      "11 : 10\n",
      "98 : 9\n",
      "45 : 8\n",
      "92 : 15\n",
      "76 : 6\n",
      "85 : 10\n",
      "16 : 12\n",
      "0 : 12\n",
      "73 : 9\n",
      "11 : 10\n",
      "85 : 10\n",
      "24 : 15\n",
      "75 : 8\n",
      "65 : 13\n",
      "28 : 15\n",
      "22 : 9\n",
      "33 : 19\n",
      "64 : 12\n",
      "38 : 8\n",
      "81 : 12\n",
      "70 : 7\n",
      "52 : 13\n",
      "40 : 17\n",
      "61 : 7\n",
      "92 : 15\n",
      "14 : 11\n",
      "39 : 12\n",
      "18 : 3\n",
      "6 : 13\n",
      "59 : 6\n",
      "12 : 7\n",
      "35 : 11\n",
      "64 : 12\n",
      "55 : 15\n",
      "65 : 13\n",
      "86 : 8\n",
      "17 : 6\n",
      "34 : 14\n",
      "8 : 15\n",
      "64 : 12\n",
      "79 : 15\n",
      "9 : 4\n",
      "4 : 10\n",
      "74 : 9\n",
      "53 : 18\n",
      "39 : 12\n",
      "8 : 15\n",
      "97 : 13\n",
      "57 : 10\n",
      "99 : 10\n",
      "81 : 12\n",
      "69 : 6\n",
      "33 : 19\n",
      "94 : 9\n",
      "44 : 8\n",
      "19 : 8\n",
      "0 : 12\n",
      "22 : 9\n",
      "9 : 4\n",
      "40 : 17\n",
      "87 : 4\n",
      "57 : 10\n",
      "40 : 17\n",
      "55 : 15\n",
      "21 : 5\n",
      "24 : 15\n",
      "65 : 13\n",
      "51 : 8\n",
      "55 : 15\n",
      "5 : 14\n",
      "84 : 6\n",
      "34 : 14\n",
      "34 : 14\n",
      "46 : 7\n",
      "91 : 12\n",
      "96 : 6\n",
      "88 : 14\n",
      "66 : 12\n",
      "50 : 10\n",
      "7 : 11\n",
      "90 : 9\n",
      "78 : 8\n",
      "36 : 5\n",
      "31 : 7\n",
      "35 : 11\n",
      "33 : 19\n",
      "4 : 10\n",
      "32 : 7\n",
      "83 : 9\n",
      "8 : 15\n",
      "31 : 7\n",
      "73 : 9\n",
      "14 : 11\n",
      "35 : 11\n",
      "22 : 9\n",
      "60 : 8\n",
      "49 : 8\n",
      "26 : 8\n",
      "55 : 15\n",
      "65 : 13\n",
      "22 : 9\n",
      "68 : 6\n",
      "69 : 6\n",
      "40 : 17\n",
      "19 : 8\n",
      "55 : 15\n",
      "76 : 6\n",
      "62 : 14\n",
      "75 : 8\n",
      "39 : 12\n",
      "28 : 15\n",
      "5 : 14\n",
      "56 : 10\n",
      "45 : 8\n",
      "60 : 8\n",
      "30 : 12\n",
      "68 : 6\n",
      "97 : 13\n",
      "48 : 8\n",
      "43 : 10\n",
      "8 : 15\n",
      "86 : 8\n",
      "62 : 14\n",
      "72 : 9\n",
      "68 : 6\n",
      "3 : 8\n",
      "57 : 10\n",
      "92 : 15\n",
      "99 : 10\n",
      "37 : 14\n",
      "92 : 15\n",
      "10 : 16\n",
      "52 : 13\n",
      "22 : 9\n",
      "28 : 15\n",
      "89 : 8\n",
      "95 : 7\n",
      "13 : 6\n",
      "65 : 13\n",
      "79 : 15\n",
      "33 : 19\n",
      "5 : 14\n",
      "16 : 12\n",
      "41 : 8\n",
      "62 : 14\n",
      "88 : 14\n",
      "29 : 9\n",
      "3 : 8\n",
      "42 : 14\n",
      "19 : 8\n",
      "6 : 13\n",
      "79 : 15\n",
      "71 : 10\n",
      "78 : 8\n",
      "39 : 12\n",
      "82 : 10\n",
      "30 : 12\n",
      "1 : 14\n",
      "83 : 9\n",
      "38 : 8\n",
      "73 : 9\n",
      "48 : 8\n",
      "51 : 8\n",
      "65 : 13\n",
      "56 : 10\n",
      "1 : 14\n",
      "55 : 15\n",
      "86 : 8\n",
      "48 : 8\n",
      "58 : 10\n",
      "56 : 10\n",
      "92 : 15\n",
      "77 : 14\n",
      "94 : 9\n",
      "77 : 14\n",
      "55 : 15\n",
      "29 : 9\n",
      "88 : 14\n",
      "58 : 10\n",
      "32 : 7\n",
      "20 : 11\n",
      "5 : 14\n",
      "83 : 9\n",
      "6 : 13\n",
      "72 : 9\n",
      "34 : 14\n",
      "6 : 13\n",
      "24 : 15\n",
      "2 : 8\n",
      "44 : 8\n",
      "81 : 12\n",
      "74 : 9\n",
      "66 : 12\n",
      "88 : 14\n",
      "53 : 18\n",
      "77 : 14\n",
      "16 : 12\n",
      "23 : 10\n",
      "81 : 12\n",
      "56 : 10\n",
      "11 : 10\n",
      "52 : 13\n",
      "66 : 12\n",
      "54 : 15\n",
      "81 : 12\n",
      "12 : 7\n",
      "100 : 14\n",
      "24 : 15\n",
      "55 : 15\n",
      "23 : 10\n",
      "79 : 15\n",
      "54 : 15\n",
      "10 : 16\n",
      "96 : 6\n",
      "27 : 7\n",
      "35 : 11\n",
      "37 : 14\n",
      "97 : 13\n",
      "37 : 14\n",
      "61 : 7\n",
      "43 : 10\n",
      "26 : 8\n",
      "27 : 7\n",
      "34 : 14\n",
      "67 : 12\n",
      "15 : 6\n",
      "12 : 7\n",
      "50 : 10\n",
      "14 : 11\n",
      "51 : 8\n",
      "90 : 9\n",
      "58 : 10\n",
      "38 : 8\n",
      "92 : 15\n",
      "7 : 11\n",
      "14 : 11\n",
      "1 : 14\n",
      "62 : 14\n",
      "1 : 14\n",
      "99 : 10\n",
      "93 : 6\n",
      "92 : 15\n",
      "66 : 12\n",
      "1 : 14\n",
      "71 : 10\n",
      "54 : 15\n",
      "57 : 10\n",
      "21 : 5\n",
      "4 : 10\n",
      "50 : 10\n",
      "88 : 14\n",
      "10 : 16\n",
      "81 : 12\n",
      "67 : 12\n",
      "86 : 8\n",
      "99 : 10\n",
      "52 : 13\n",
      "98 : 9\n",
      "6 : 13\n",
      "10 : 16\n",
      "34 : 14\n",
      "66 : 12\n",
      "99 : 10\n",
      "38 : 8\n",
      "49 : 8\n",
      "51 : 8\n",
      "38 : 8\n",
      "100 : 14\n",
      "66 : 12\n",
      "33 : 19\n",
      "37 : 14\n",
      "94 : 9\n",
      "1 : 14\n",
      "84 : 6\n",
      "41 : 8\n",
      "89 : 8\n",
      "34 : 14\n",
      "30 : 12\n",
      "7 : 11\n",
      "0 : 12\n",
      "42 : 14\n",
      "45 : 8\n",
      "70 : 7\n",
      "78 : 8\n",
      "53 : 18\n",
      "8 : 15\n",
      "35 : 11\n",
      "93 : 6\n",
      "50 : 10\n",
      "30 : 12\n",
      "94 : 9\n",
      "33 : 19\n",
      "87 : 4\n",
      "37 : 14\n",
      "8 : 15\n",
      "95 : 7\n",
      "54 : 15\n",
      "39 : 12\n",
      "46 : 7\n",
      "42 : 14\n",
      "22 : 9\n",
      "42 : 14\n",
      "20 : 11\n",
      "53 : 18\n",
      "33 : 19\n",
      "22 : 9\n",
      "83 : 9\n",
      "30 : 12\n",
      "81 : 12\n",
      "30 : 12\n",
      "52 : 13\n",
      "43 : 10\n",
      "1 : 14\n",
      "52 : 13\n",
      "71 : 10\n",
      "91 : 12\n",
      "50 : 10\n",
      "77 : 14\n",
      "44 : 8\n",
      "92 : 15\n",
      "31 : 7\n",
      "64 : 12\n",
      "84 : 6\n",
      "75 : 8\n",
      "79 : 15\n",
      "78 : 8\n",
      "49 : 8\n",
      "65 : 13\n",
      "42 : 14\n",
      "72 : 9\n",
      "40 : 17\n",
      "63 : 4\n",
      "37 : 14\n",
      "67 : 12\n",
      "21 : 5\n",
      "62 : 14\n",
      "97 : 13\n",
      "75 : 8\n",
      "40 : 17\n",
      "40 : 17\n",
      "79 : 15\n",
      "2 : 8\n",
      "50 : 10\n",
      "31 : 7\n",
      "3 : 8\n",
      "80 : 11\n",
      "92 : 15\n",
      "54 : 15\n",
      "52 : 13\n",
      "52 : 13\n",
      "96 : 6\n",
      "48 : 8\n",
      "28 : 15\n",
      "81 : 12\n",
      "77 : 14\n",
      "77 : 14\n",
      "0 : 12\n",
      "80 : 11\n",
      "9 : 4\n",
      "82 : 10\n",
      "40 : 17\n",
      "53 : 18\n",
      "19 : 8\n",
      "48 : 8\n",
      "6 : 13\n",
      "95 : 7\n",
      "82 : 10\n",
      "80 : 11\n",
      "86 : 8\n",
      "67 : 12\n",
      "98 : 9\n",
      "91 : 12\n",
      "33 : 19\n",
      "59 : 6\n",
      "80 : 11\n",
      "95 : 7\n",
      "11 : 10\n",
      "69 : 6\n",
      "74 : 9\n",
      "55 : 15\n",
      "14 : 11\n",
      "20 : 11\n",
      "28 : 15\n",
      "74 : 9\n",
      "72 : 9\n",
      "24 : 15\n",
      "16 : 12\n",
      "55 : 15\n",
      "28 : 15\n",
      "7 : 11\n",
      "28 : 15\n",
      "53 : 18\n",
      "74 : 9\n",
      "10 : 16\n",
      "67 : 12\n",
      "96 : 6\n",
      "3 : 8\n",
      "7 : 11\n",
      "12 : 7\n",
      "27 : 7\n",
      "42 : 14\n",
      "40 : 17\n",
      "47 : 5\n",
      "33 : 19\n",
      "11 : 10\n",
      "79 : 15\n",
      "61 : 7\n",
      "67 : 12\n",
      "88 : 14\n",
      "70 : 7\n",
      "15 : 6\n",
      "13 : 6\n",
      "16 : 12\n",
      "71 : 10\n",
      "28 : 15\n",
      "42 : 14\n",
      "34 : 14\n",
      "77 : 14\n",
      "85 : 10\n",
      "82 : 10\n",
      "97 : 13\n",
      "73 : 9\n",
      "73 : 9\n",
      "26 : 8\n",
      "58 : 10\n",
      "12 : 7\n",
      "72 : 9\n",
      "10 : 16\n",
      "97 : 13\n",
      "84 : 6\n",
      "56 : 10\n",
      "37 : 14\n",
      "6 : 13\n",
      "8 : 15\n",
      "37 : 14\n",
      "43 : 10\n",
      "33 : 19\n",
      "95 : 7\n",
      "81 : 12\n",
      "63 : 4\n",
      "43 : 10\n",
      "16 : 12\n",
      "61 : 7\n",
      "91 : 12\n",
      "68 : 6\n",
      "64 : 12\n",
      "0 : 12\n",
      "22 : 9\n",
      "88 : 14\n",
      "10 : 16\n",
      "67 : 12\n",
      "62 : 14\n",
      "79 : 15\n",
      "70 : 7\n",
      "35 : 11\n",
      "92 : 15\n",
      "94 : 9\n",
      "29 : 9\n",
      "91 : 12\n",
      "20 : 11\n",
      "30 : 12\n",
      "58 : 10\n",
      "43 : 10\n",
      "65 : 13\n",
      "85 : 10\n",
      "78 : 8\n",
      "28 : 15\n",
      "1 : 14\n",
      "18 : 3\n",
      "14 : 11\n",
      "29 : 9\n",
      "43 : 10\n",
      "62 : 14\n",
      "2 : 8\n",
      "100 : 14\n",
      "22 : 9\n",
      "23 : 10\n",
      "53 : 18\n",
      "71 : 10\n",
      "13 : 6\n",
      "25 : 9\n",
      "10 : 16\n",
      "71 : 10\n",
      "31 : 7\n",
      "94 : 9\n",
      "64 : 12\n",
      "29 : 9\n",
      "91 : 12\n",
      "100 : 14\n",
      "39 : 12\n",
      "8 : 15\n",
      "98 : 9\n",
      "82 : 10\n",
      "4 : 10\n",
      "100 : 14\n",
      "57 : 10\n",
      "99 : 10\n",
      "62 : 14\n",
      "47 : 5\n",
      "68 : 6\n",
      "96 : 6\n",
      "98 : 9\n",
      "25 : 9\n",
      "34 : 14\n",
      "10 : 16\n",
      "5 : 14\n",
      "48 : 8\n",
      "39 : 12\n",
      "16 : 12\n",
      "10 : 16\n",
      "2 : 8\n",
      "54 : 15\n",
      "64 : 12\n",
      "56 : 10\n",
      "53 : 18\n",
      "85 : 10\n",
      "1 : 14\n",
      "100 : 14\n",
      "55 : 15\n",
      "70 : 7\n",
      "16 : 12\n",
      "40 : 17\n",
      "56 : 10\n",
      "63 : 4\n",
      "57 : 10\n",
      "53 : 18\n",
      "52 : 13\n",
      "83 : 9\n",
      "20 : 11\n",
      "49 : 8\n",
      "60 : 8\n",
      "93 : 6\n",
      "64 : 12\n",
      "27 : 7\n",
      "77 : 14\n",
      "29 : 9\n",
      "100 : 14\n",
      "86 : 8\n",
      "57 : 10\n",
      "10 : 16\n",
      "89 : 8\n",
      "8 : 15\n",
      "35 : 11\n",
      "20 : 11\n",
      "27 : 7\n",
      "4 : 10\n",
      "95 : 7\n",
      "2 : 8\n",
      "40 : 17\n",
      "98 : 9\n",
      "57 : 10\n",
      "54 : 15\n",
      "66 : 12\n",
      "55 : 15\n",
      "90 : 9\n",
      "57 : 10\n",
      "80 : 11\n",
      "85 : 10\n",
      "97 : 13\n",
      "66 : 12\n",
      "88 : 14\n",
      "70 : 7\n",
      "66 : 12\n",
      "71 : 10\n",
      "10 : 16\n",
      "76 : 6\n",
      "98 : 9\n",
      "25 : 9\n",
      "65 : 13\n",
      "45 : 8\n",
      "87 : 4\n",
      "11 : 10\n",
      "23 : 10\n",
      "24 : 15\n",
      "65 : 13\n",
      "76 : 6\n",
      "34 : 14\n",
      "62 : 14\n",
      "41 : 8\n",
      "6 : 13\n",
      "15 : 6\n",
      "39 : 12\n",
      "14 : 11\n",
      "32 : 7\n",
      "90 : 9\n",
      "4 : 10\n",
      "78 : 8\n",
      "33 : 19\n",
      "35 : 11\n",
      "14 : 11\n",
      "49 : 8\n",
      "99 : 10\n",
      "30 : 12\n",
      "42 : 14\n",
      "53 : 18\n",
      "1 : 14\n",
      "39 : 12\n",
      "0 : 12\n",
      "36 : 5\n",
      "25 : 9\n",
      "5 : 14\n",
      "8 : 15\n",
      "92 : 15\n",
      "12 : 7\n",
      "32 : 7\n",
      "83 : 9\n",
      "58 : 10\n",
      "17 : 6\n",
      "68 : 6\n",
      "43 : 10\n",
      "5 : 14\n",
      "11 : 10\n",
      "5 : 14\n",
      "94 : 9\n",
      "67 : 12\n",
      "45 : 8\n",
      "91 : 12\n",
      "7 : 11\n",
      "7 : 11\n",
      "37 : 14\n",
      "80 : 11\n",
      "56 : 10\n",
      "64 : 12\n",
      "97 : 13\n",
      "79 : 15\n",
      "85 : 10\n",
      "88 : 14\n",
      "53 : 18\n",
      "62 : 14\n",
      "5 : 14\n",
      "89 : 8\n",
      "53 : 18\n",
      "13 : 6\n",
      "91 : 12\n",
      "33 : 19\n",
      "97 : 13\n",
      "10 : 16\n",
      "28 : 15\n",
      "89 : 8\n",
      "55 : 15\n",
      "4 : 10\n",
      "85 : 10\n",
      "25 : 9\n",
      "43 : 10\n",
      "40 : 17\n",
      "47 : 5\n",
      "26 : 8\n",
      "64 : 12\n",
      "20 : 11\n",
      "67 : 12\n",
      "34 : 14\n",
      "90 : 9\n",
      "100 : 14\n",
      "23 : 10\n",
      "30 : 12\n",
      "13 : 6\n",
      "30 : 12\n",
      "94 : 9\n",
      "87 : 4\n",
      "24 : 15\n",
      "94 : 9\n",
      "26 : 8\n",
      "29 : 9\n",
      "99 : 10\n",
      "99 : 10\n",
      "92 : 15\n",
      "17 : 6\n",
      "56 : 10\n",
      "67 : 12\n",
      "59 : 6\n",
      "32 : 7\n",
      "76 : 6\n",
      "48 : 8\n",
      "60 : 8\n",
      "64 : 12\n",
      "27 : 7\n",
      "90 : 9\n",
      "25 : 9\n",
      "97 : 13\n",
      "73 : 9\n",
      "41 : 8\n",
      "38 : 8\n",
      "19 : 8\n",
      "0 : 12\n",
      "54 : 15\n",
      "80 : 11\n",
      "74 : 9\n",
      "92 : 15\n",
      "52 : 13\n",
      "62 : 14\n",
      "51 : 8\n",
      "2 : 8\n",
      "15 : 6\n",
      "34 : 14\n",
      "19 : 8\n",
      "40 : 17\n",
      "54 : 15\n",
      "56 : 10\n",
      "4 : 10\n",
      "66 : 12\n",
      "15 : 6\n",
      "33 : 19\n",
      "5 : 14\n",
      "9 : 4\n",
      "96 : 6\n",
      "99 : 10\n",
      "35 : 11\n",
      "8 : 15\n",
      "86 : 8\n",
      "89 : 8\n",
      "30 : 12\n",
      "73 : 9\n",
      "6 : 13\n",
      "80 : 11\n",
      "82 : 10\n",
      "45 : 8\n",
      "81 : 12\n",
      "7 : 11\n",
      "20 : 11\n",
      "78 : 8\n",
      "82 : 10\n",
      "71 : 10\n",
      "8 : 15\n",
      "59 : 6\n",
      "42 : 14\n",
      "40 : 17\n",
      "5 : 14\n",
      "11 : 10\n",
      "24 : 15\n",
      "91 : 12\n",
      "39 : 12\n"
     ]
    }
   ],
   "source": [
    "import random\n",
    "x = [random.randint(0,100)for i in range(1000)]\n",
    "print(x)\n",
    "for i in x:\n",
    "    print(i,':',x.count(i))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "165px"
   },
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
